package com.example.barcodeapp.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.example.barcodeapp.R;
import com.example.barcodeapp.adapter.ownadapter.AdapterXilei;
import com.luck.picture.lib.tools.ScreenUtils;

public class KeChengXiangQingAdapter extends RecyclerView.Adapter<KeChengXiangQingAdapter.ViewHolder> {
    Context context;

    public KeChengXiangQingAdapter(Context context) {
        this.context = context;
    }
    private KeChengXiangQingAdapter.IClick callback;
    public void setClick(KeChengXiangQingAdapter.IClick cb){
        callback = cb;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.adapter_xiangqingjiemian, parent, false);
        return new ViewHolder(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {

        if (position==2||position==5){
            holder.neirongxinagqing.setTextColor(Color.parseColor("#ff9b9b9b"));

            Glide.with(context).load(R.drawable.suo).into(holder.imageView8);
            holder.imageView8.getLayoutParams().height = 60;
            holder.imageView8.getLayoutParams().width = 60;
            holder.imageView8.requestLayout();
            holder.shijian.setVisibility(View.INVISIBLE);
        }else {
            holder.neirongxinagqing.setTextColor(Color.parseColor("#ff393939"));
            Glide.with(context).load(R.mipmap.shangkeshijian).into(holder.imageView8);
                 holder.shijian.setVisibility(View.VISIBLE);
        }



        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                callback.click(position);
            }
        });

    }

    @Override
    public int getItemCount() {
        return 10;
    }


    public class ViewHolder extends RecyclerView.ViewHolder {

        private TextView textView22;
        private TextView textView23;
        private TextView textView24;
        private TextView textView25;
        private ImageView imageView8;
        private TextView neirongxinagqing;
        private TextView shijian;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            textView22 = (TextView) itemView.findViewById(R.id.textView22);
            textView23 = (TextView) itemView.findViewById(R.id.textView23);
            textView24 = (TextView) itemView.findViewById(R.id.textView24);
            textView25 = (TextView) itemView.findViewById(R.id.textView25);
            neirongxinagqing = (TextView) itemView.findViewById(R.id.neirong_xiangqing);
            shijian = (TextView) itemView.findViewById(R.id.shijian);
            imageView8 = (ImageView) itemView.findViewById(R.id.imageView8);
        }
    }


    public interface IClick{
        void click(int pos);
    }

}
